package com.wu.client.constant;

import com.wu.common.convertion.exception.ServiceException;
import lombok.AllArgsConstructor;
import lombok.Getter;

@AllArgsConstructor
@Getter
public enum RelationShipTypeEnum {

    ARTIST_SONG("歌手-歌曲",1),PLAYLIST_SONG("歌单-歌曲",2),ALBUM_SONG("专辑-歌曲",3),
    USER_PLAYLIST("用户-歌单",4),ARTIST_ALBUM("歌手-专辑",5),ARTIST_MV("歌手-MV",6);
    /**
     * 映射类型(1：歌手-歌曲 2：歌单-歌曲 3：专辑-歌曲 4：用户-歌单 5：歌手-专辑 6：歌手-MV)
     */
    private final String desc;
    private final Integer code;
    public static RelationShipTypeEnum getByCode(Integer code) {
        for (RelationShipTypeEnum value : RelationShipTypeEnum.values()) {
            if (value.getCode().equals(code)) {
                return value;
            }
        }
        throw new ServiceException("实体映射传参错误："+code);
    }

}
